var app = angular.module('app');
app.factory('signUpImportService', ['$http', '$q', 'server', 'Upload', function ($http, $q, server, Upload) {
    var signUpImportService = {};
    signUpImportService.uploadFile = function (file, errFiles, activityId) {
        var deferred = $q.defer();
        if (file) {
            file.upload = Upload.upload({
                url: server.addr + '/activity/' + activityId + '/signUp/import',
                data: {file: file}
            });

            file.upload.then(function (response) {
                deferred.resolve(response.data);
            }, function (response) {
                deferred.reject(response.data);
            }, function (event) {
                deferred.notify(event);
            });
            return deferred.promise;
        } else {
            deferred.reject();
        }
    };

    return signUpImportService;
}]);